
//继承的作用：对共性的抽取，从而达到了对代码的复用效果
//继承是 is a 的关系（归属关系），如 Dog is a Animal；Bird is a Animal

class Animal {//父类/基类/超类
    public String name;
    public int age;
    public String colour;

    public void eat() {
        System.out.println(name + "正在吃饭......");
    }
}

class Dog extends Animal {//继承 子类/派生类
    public Dog(String name, int age, String colour) {//生成带有三个参数的构造方法
        this.name = name;
        this.age = age;
        this.colour = colour;
    }

    public void bark() {
        System.out.println(name + "正在汪汪叫......");
    }
}

class Bird extends Animal {//继承
    public Bird(String name, int age, String colour) {//生成带有三个参数的构造方法
        this.name = name;
        this.age = age;
        this.colour = colour;
    }

    public void fly() {
        System.out.println(name + "正在飞......");
    }
}

public class Test1 {
    public static void main(String[] args) {//不要忘记了main方法
        Dog dog = new Dog("小黄", 1, "黄色");//实例化了Dog这样的对象
        Bird bird = new Bird("小云", 2, "蓝色");
        bird.fly();
    }
}
